package com.jessechanrui.template.database.mybatisplus.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.jessechanrui.template.database.mybatisplus.entity.enums.SexEnum;
import com.jessechanrui.template.database.mybatisplus.entity.vo.TestVO;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName(value="rob_user", autoResultMap = true)
public class UserDO {

    /**
     * 主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 昵称
     */

    @TableField(value = "nickname")
    private String nickname;


    //@TableField(value = "test",typeHandler = CustomTypeHandler.class)
    //private Test2VO test;

    @TableField(value = "test", typeHandler = FastjsonTypeHandler.class)
    private TestVO test;

    /**
     * 性别
     */
    @TableField(value = "sex")
    //局部序列化枚举类型
    @JSONField(serialzeFeatures= SerializerFeature.WriteEnumUsingToString)
    private SexEnum sex;

    /**
     * 版本
     */
    @TableField(value = "version",update = "%s+1")
    private Integer version;

    /**
     * 时间字段，自动添加
     */
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;


}
